﻿using HCQ2_Common;
using HCQ2_Common.Constant;
using HCQ2_Model;
using HCQ2_Model.ViewModel.WebAPI;
using HCQ2_Model.VLine.InputDto._0410;
using HCQ2_Model.VLine.InputDto._0416;
using HCQ2_Model.VLine.OutputDto;
using HCQ2_Model.VLine.OutputDto._0416;
using HCQ2_Model.VLine.Params;
using HCQ2_Model.VRDD.InputDto;
using HCQ2_Model.VRDD.InputDto._0427;
using HCQ2_Model.VRDD.InputDto._0525;
using HCQ2_Model.VRDD.InputDto._0602;
using HCQ2_Model.VRDD.OutputDto._0427;
using HCQ2_Model.VRDD.OutputDto._0525;
using HCQ2_Model.VRDD.OutputDto._0602;
using HCQ2UI_Helper.Session;
using HCQ2WebAPI_Logic.BaseAPIController;
using HCQ2WebAPI_Logic.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace HCQ2WebAPI_Logic.DocumentController
{
    /// <summary>
    ///  VR度度圈【2021-05-25】【2021-06-02】需求
    ///  个人动态
    /// </summary>
    public class VRCircleDynamicController : BaseWeiXinApiLogic
    {
        //****************************************************2021-05-25需求*******************************************************
        #region  1.2 ✔ 获取人脉关系 + WebApiResultJsonModel GetRelationship(InputRelationShip param)
        /// <summary>
        ///  1.2 ✔ 获取人脉关系
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        /// <remarks>
        ///  数据返回：null 【表示两者之间没有关系】
        /// </remarks>
        [HttpPost]
        public WebApiResultJsonModel<List<OutputRelationShip>> GetRelationship(InputRelationShip param)
        {
            //1.0 验证数据有效性
            if (!ModelState.IsValid)
                return ApiResultJsonModel<List<OutputRelationShip>>.RedirectWebApi(WebResultCode.Exception, getErrorMessage(ModelState), null);
            List<OutputRelationShip> list = operateContext.bllSession.T_VRDDCircleDynamic.GetRelationship(param);
            return ApiResultJsonModel<List<OutputRelationShip>>.RedirectWebApi(WebResultCode.Ok, "成功获取人脉关系~", list);
        }
        #endregion

        #region 1.3 ✔保存个人动态 + async Task<WebApiResultJsonModel> SaveUserDynamic()
        /// <summary>
        ///  1.3 ✔保存个人动态
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// 提交方式：Form表单提交<br/>
        /// 表单参数：<br/>
        /// user_id【必填】： int 用户id<br/>
        /// hide_dynamic【必填】：int 谁可以看动态【公开=2、好友可见=1、私密=0】<br/>
        /// d_note【必填】：string 动态描述<br/>
        /// gps_x【非必填】： decimal 经度<br/>
        /// gps_y【非必填】： decimal 纬度<br/>
        /// create_url【非必填】：string 所在地<br/>
        /// proType【非必填】string 动态来源 【VCircle=度度圈（默认值）；VMeta=元宇宙】<br/>
        /// video【非必填】：file 视频文件【允许多个文件】<br/>
        /// picture【非必填】：file 图片文件【允许多个文件】<br/>
        /// 20220616 需求1.6增加以下参数proType
        /// </remarks>
        [HttpPost]
        public async Task<WebApiResultJsonModel> SaveUserDynamic()
        {
            int user_id = RequestHelper.GetIntByName("user_id"),//用户id
                hide_dynamic = RequestHelper.GetIntByName("hide_dynamic");//谁可以看动态
            decimal gps_x = RequestHelper.GetDecimalByName("gps_x"),
                gps_y = RequestHelper.GetDecimalByName("gps_y");
            string d_note = RequestHelper.GetStrByName("d_note"),
                create_url = RequestHelper.GetStrByName("create_url");
            string proType = RequestHelper.GetStrByName("proType");
            T_User user = operateContext.bllSession.T_User.Select(s => s.user_id == user_id).FirstOrDefault();
            if(user==null)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "用户id信息异常~", "");
            //图片上传路径
            string pathServer = $"/uploadFile/DDFile/" + user.user_guid + "/" + DateTime.Now.ToString("yyyyMMdd") + "/Breviary/";
            string uploadPath = request.MapPath(request.ApplicationPath + pathServer);
            if (!Directory.Exists(uploadPath))
                Directory.CreateDirectory(uploadPath);
            CustomMultipartFormDataStreamProvider provider = new CustomMultipartFormDataStreamProvider(uploadPath);
            //定义上传文件名称【图片】
            List<string> upFileNames = new List<string>();//文件存放路径
            List<string> oldFileNames = new List<string>();//原始文件名称
            //定义上传文件名称【视频】
            List<string> upVideoFileNames = new List<string>();//文件存放路径
            List<string> oldVideoFileNames = new List<string>();//原始文件名称
            try
            {
                //上传附件
                await Request.Content.ReadAsMultipartAsync(provider);
                //获取原始文件名称
                foreach (MultipartFileData file in provider.FileData)
                {
                    string fileTypeName = file.Headers.ContentDisposition.Name.Trim('"');
                    if (fileTypeName.Equals("picture"))
                    {
                        upFileNames.Add(Path.GetFileName(file.LocalFileName));
                        oldFileNames.Add(file.Headers.ContentDisposition.Name.Replace("\"", string.Empty));
                    }else
                    {
                        upVideoFileNames.Add(Path.GetFileName(file.LocalFileName));
                        oldVideoFileNames.Add(file.Headers.ContentDisposition.Name.Replace("\"", string.Empty));
                    }   
                }
                T_VRDDCircleDynamic dy = new T_VRDDCircleDynamic
                {
                    du_id = user_id,
                    d_note = d_note,
                    gps_x = gps_x,
                    gps_y = gps_y,
                    hide_dynamic = hide_dynamic,
                    star_num = 0,
                    create_id = user_id,
                    create_name = user.user_name,
                    create_date = DateTime.Now,
                    create_url = create_url,
                    update_date = DateTime.Now,
                    dy_source = proType
                };
                int mark = operateContext.bllSession.T_VRDDCircleDynamic.Add(dy);
                if(mark<=0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "保存个人动态失败~", "");
                //判断是否获取到了附件名称
                if ((upFileNames == null || upFileNames.Count <= 0) && (upVideoFileNames == null || upVideoFileNames.Count <= 0))
                {
                    foreach (string item in upFileNames)
                        File.Delete(uploadPath + item);
                    foreach (string item in upVideoFileNames)
                        File.Delete(uploadPath + item);
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "成功保存个人动态~", "");
                }
                else
                {
                    #region 有上传附件【图片】
                    for (int i = 0; i < upFileNames.Count; i++)
                    {
                        operateContext.bllSession.T_VRDDCirclePicList.Add(new T_VRDDCirclePicList
                        {
                            du_id = dy.du_id,
                            d_id = dy.id,
                            img_name = oldFileNames[i].ToString(),
                            img_url = "~" + pathServer + upFileNames[i].ToString(),//文件存放路径,
                            create_date = DateTime.Now,
                            update_date = DateTime.Now
                        });
                    }
                    #endregion

                    #region 有上传附件【视频】
                    for (int i = 0; i < upVideoFileNames.Count; i++)
                    {
                        operateContext.bllSession.T_VRDDCircleVideoList.Add(new T_VRDDCircleVideoList
                        {
                            du_id = dy.du_id,
                            d_id = dy.id,
                            video_name = oldVideoFileNames[i].ToString(),
                            video_url = "~" + pathServer + upVideoFileNames[i].ToString(),//文件存放路径,
                            create_date = DateTime.Now,
                            update_date = DateTime.Now
                        });
                    }
                    #endregion
                }
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "成功保存个人动态~", "");
            }
            catch(Exception ex)
            {
                foreach (string item in upFileNames)
                    File.Delete(uploadPath + item);
                foreach (string item in upVideoFileNames)
                    File.Delete(uploadPath + item);
                throw ex;
                //return ApiResultJsonModel.RedirectWebApi(WebResultCode.Error, "保存个人动态失败", null);
            }  
        }
        #endregion

        #region  1.4 ✔ 获取动态信息列表 + WebApiResultJsonModel GetDynamicList(InputDynamicList param)
        /// <summary>
        ///  1.4 ✔ 获取动态信息列表
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        /// <remarks>20220616需求1.7 增加以下参数proType</remarks>
        [HttpPost]
        public WebApiResultJsonModel<List<OutputDynamicResult>> GetDynamicList(InputDynamicList param)
        {
            //1.0 验证数据有效性
            if (!ModelState.IsValid)
                return ApiResultJsonModel<List<OutputDynamicResult>>.RedirectWebApi(WebResultCode.Exception, getErrorMessage(ModelState), null);
            List<OutputDynamicResult> list = operateContext.bllSession.T_VRDDCircleDynamic.GetDynamicList(param);
            return ApiResultJsonModel<List<OutputDynamicResult>>.RedirectWebApi(WebResultCode.Ok, "成功获取动态信息列表~", list);
        }
        #endregion

        #region  1.5 ✔提交对动态已读状态 + WebApiResultJsonModel SubmitDyStatus(InputDynamicStatus param)
        /// <summary>
        ///  1.5 ✔提交对动态已读状态
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        [HttpPost]
        public WebApiResultJsonModel SubmitDyStatus(InputDynamicStatus param)
        {
            //1.0 验证数据有效性
            if (param.user_id<=0 || param.dy_id<=0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "用户id和动态id都是必填项！", null);
            //判断用户-动态是否已经阅读
            int mark = operateContext.bllSession.T_VRDDCircleReadDynamic.SelectCount(s => s.du_id == param.user_id && s.d_id == param.dy_id);
            if(mark>0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "成功添加已读~", "");
            mark = operateContext.bllSession.T_User.SelectCount(s => s.user_id == param.user_id);
            if(mark<=0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "用户id信息异常！", null);
            mark = operateContext.bllSession.T_VRDDCircleDynamic.SelectCount(s => s.id == param.dy_id);
            if (mark <= 0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "动态id信息异常！", null);
            //添加已读
            mark = operateContext.bllSession.T_VRDDCircleReadDynamic.Add(new T_VRDDCircleReadDynamic
            {
                du_id = param.user_id,
                d_id = param.dy_id,
                read_date = DateTime.Now
            });
            if(mark>0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "添加已读成功~", "");
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "添加已读失败！", null);
        }
        #endregion

        #region  1.6 ✔提交对动态的点赞 + WebApiResultJsonModel SubmitDyStar(InputDynamicStar param)
        /// <summary>
        ///  1.6 ✔提交对动态的点赞
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        [HttpPost]
        public WebApiResultJsonModel SubmitDyStar(InputDynamicStar param)
        {
            //1.0 验证数据有效性
            if (param.user_id <= 0 || param.dy_id <= 0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "点赞用户id和动态id都是必填项！", null);
            int mark = operateContext.bllSession.T_User.SelectCount(s => s.user_id == param.user_id);
            if (mark <= 0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "用户id信息异常！", null);
            var dy = operateContext.bllSession.T_VRDDCircleDynamic.FindSingle(s => s.id == param.dy_id);
            if (dy==null)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "动态id信息异常！", null);
            #region 点赞
            if (param.dy_type > 0)
            {
                //提交点赞
                mark = operateContext.bllSession.T_VRDDCircleUserStar.SelectCount(s => s.du_id == param.user_id && s.d_id == param.dy_id);
                if (mark > 0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "成功添加点赞~", "");
                else
                    mark = operateContext.bllSession.T_VRDDCircleUserStar.Add(new T_VRDDCircleUserStar
                    {
                        du_id = param.user_id,
                        d_id = param.dy_id,
                        d_user_id = dy.du_id,
                        star_date = DateTime.Now,
                        star_status = false //默认未读
                    });
                if (mark > 0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "点赞成功~", "");
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "点赞失败！", null);
            }
            #endregion

            #region 取消点赞
            else
            {
                //取消点赞
                mark = operateContext.bllSession.T_VRDDCircleUserStar.SelectCount(s => s.du_id == param.user_id && s.d_id == param.dy_id);
                if(mark<=0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "当前用户尚未对此动态点赞！", null);
                mark = operateContext.bllSession.T_VRDDCircleUserStar.Delete(s => s.du_id == param.user_id && s.d_id == param.dy_id);
                if (mark > 0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "点赞取消成功~", "");
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "点赞取消失败！", null);
            }
            #endregion
        }
        #endregion

        #region  1.7 ✔提交对动态的评论 + WebApiResultJsonModel SubmitDyReview(InputDynamicReview param)
        /// <summary>
        ///  1.7 ✔提交对动态的评论
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        [HttpPost]
        public WebApiResultJsonModel SubmitDyReview(InputDynamicReview param)
        {
            //1.0 验证数据有效性
            if (param.user_id <= 0 || param.dy_id <= 0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "用户id和动态id都是必填项！", null);
            if(param.re_type>0 && string.IsNullOrEmpty(param.re_note))
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "提交评论时评论内容为必填项！", null);
            int mark = operateContext.bllSession.T_User.SelectCount(s => s.user_id == param.user_id);
            if (mark <= 0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "评论用户id信息异常！", null);
            var dy = operateContext.bllSession.T_VRDDCircleDynamic.FindSingle(s => s.id == param.dy_id);
            if (dy == null)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "动态id信息异常！", null);
            #region 提交评论
            if (param.re_type > 0)
            {
                //提交评论
                //mark = operateContext.bllSession.T_VRDDCircleUserReview.SelectCount(s => s.du_id == param.user_id && s.d_id == param.dy_id && s.re_note.Equals(param.re_note));
                //if (mark > 0)
                //    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "成功添加评论~", "");
                //else
                mark = operateContext.bllSession.T_VRDDCircleUserReview.Add(new T_VRDDCircleUserReview
                {
                    du_id = param.user_id,
                    d_id = param.dy_id,
                    d_user_id = dy.du_id,
                    re_note=param.re_note,
                    re_date = DateTime.Now,
                    re_status = false //默认未读
                });
                if (mark > 0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "评论成功~", "");
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "评论失败！", null);
            }
            #endregion

            #region 取消评论
            else
            {
                if(param.id<=0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "删除评论必传评论id！", null);
                //取消点赞
                mark = operateContext.bllSession.T_VRDDCircleUserReview.SelectCount(s => s.id == param.id && s.du_id == param.user_id && s.d_id == param.dy_id);
                if (mark <= 0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "当前用户尚未对此动态评论！", null);
                mark = operateContext.bllSession.T_VRDDCircleUserReview.Delete(s => s.id == param.id);
                if (mark > 0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "评论取消成功~", "");
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "评论取消失败！", null);
            }
            #endregion
        }
        #endregion

        #region  1.8 ✔获取未读的点赞及评论列表 + WebApiResultJsonModel GetUnreadDynamicList(DDBaseUser param)
        /// <summary>
        ///  1.8 ✔获取未读的点赞及评论列表
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        [HttpPost]
        public WebApiResultJsonModel<List<OutputUnreadDynamicList>> GetUnreadDynamicList(DDBaseUser param)
        {
            //1.0 验证数据有效性
            if (!ModelState.IsValid)
                return ApiResultJsonModel<List<OutputUnreadDynamicList>>.RedirectWebApi(WebResultCode.Exception, getErrorMessage(ModelState), null);
            List<OutputUnreadDynamicList> list = operateContext.bllSession.T_VRDDCircleDynamic.GetUnreadDynamicList(param);
            return ApiResultJsonModel<List<OutputUnreadDynamicList>>.RedirectWebApi(WebResultCode.Ok, "成功获取未读的点赞及评论列表~", list);
        }
        #endregion

        //****************************************************2021-06-02需求*******************************************************
        #region 2.0 ✔保存服务信息 + async Task<WebApiResultJsonModel> SaveUserService()
        /// <summary>
        ///  2.0 ✔保存服务信息
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// 提交方式：Form表单提交<br/>
        /// 表单参数：<br/>
        /// user_id【必填】： int 用户id<br/>
        /// voice【必填】：file 音频文件<br/>
        /// voice_len【必填】： int 音频时长<br/>
        /// bs_range【必填】： int 发布范围【公开=0，仅好友=1，六度人脉=2，私密=3】<br/>
        /// bs_period【必填】：int 有效期【以天为单位，1周=7，2周=14，3周=21，1月=30，长期=0】<br/>
        /// bs_type【非必填】：string 服务类别
        /// </remarks>
        [HttpPost]
        public async Task<WebApiResultJsonModel> SaveUserService()
        {
            int user_id = RequestHelper.GetIntByName("user_id"),//用户id
                file_id = RequestHelper.GetIntByName("file_id"),//作品id
                voice_len = RequestHelper.GetIntByName("voice_len"),//音频时长
                 bs_range = RequestHelper.GetIntByName("bs_range"),//发布范围【公开、仅好友、六度人脉、私密】
                  bs_period = RequestHelper.GetIntByName("bs_period");//有效期
            string bs_type = RequestHelper.GetStrByName("bs_type");//服务类别
            //判断参数是否异常
            if(voice_len<=0)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "音频时长异常~", "");
            if(bs_range!=0 && bs_range!=1 && bs_range!=2 && bs_range!=3)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "发布范围请按规定传递~", "");
            //if(bs_period<=0)
            //    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "有效期以天为单位大于零的整型数据~", "");
            if (user_id > 0)
            {
                T_User user = operateContext.bllSession.T_User.Select(s => s.user_id == user_id).FirstOrDefault();
                if (user == null)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "用户id信息异常~", "");
            }
            if (file_id > 0)
            {
                int fileCount = operateContext.bllSession.T_DocumentInfo.SelectCount(s => s.file_id == file_id);
                if(fileCount<=0)
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "商铺id信息异常~", "");
            }
            //音频上传路径
            string pathServer = $"/uploadFile/DDVoiceFile/" + DateTime.Now.ToString("yyyyMMdd") + "/Breviary/";
            string uploadPath = request.MapPath(request.ApplicationPath + pathServer);
            if (!Directory.Exists(uploadPath))
                Directory.CreateDirectory(uploadPath);
            CustomMultipartFormDataStreamProvider provider = new CustomMultipartFormDataStreamProvider(uploadPath);
            //定义上传文件名称【音频】
            List<string> upFileNames = new List<string>();//文件存放路径
            List<string> oldFileNames = new List<string>();//原始文件名称
            try
            {
                //上传附件
                await Request.Content.ReadAsMultipartAsync(provider);
                //获取原始文件名称
                foreach (MultipartFileData file in provider.FileData)
                {
                    upFileNames.Add(Path.GetFileName(file.LocalFileName));
                    oldFileNames.Add(file.Headers.ContentDisposition.Name.Replace("\"", string.Empty));
                }
                //判断是否获取到了附件名称
                if ((upFileNames == null || upFileNames.Count <= 0))
                {
                    foreach (string item in upFileNames)
                        File.Delete(uploadPath + item);
                    return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, "未获取到音频文件~", "");
                }
                else
                {
                    #region 有上传附件【音频】
                    for (int i = 0; i < upFileNames.Count; i++)
                    {
                        //保存用户服务记录
                        operateContext.bllSession.T_VRDDCircleUserService.Add(new T_VRDDCircleUserService
                        {
                            du_id = user_id,
                            file_id = file_id,
                            voice_url = "~" + pathServer + upFileNames[i].ToString(),//文件存放路径,
                            voice_len = voice_len,
                            bs_type = bs_type,
                            bs_range = bs_range,
                            bs_period = bs_period,
                            create_date = DateTime.Now,
                            update_date = DateTime.Now,
                            end_date = DateTime.Now.AddDays(bs_period)
                        });
                        //判断服务类别是否需要记录进基础表
                        var obj = operateContext.bllSession.T_VRDDCircleBaseService.FindSingle(s => s.s_type.Equals(bs_type));
                        if (obj == null)
                        {
                            //添加
                            operateContext.bllSession.T_VRDDCircleBaseService.Add(new T_VRDDCircleBaseService
                            {
                                s_type = bs_type,
                                s_num = 1,
                                s_top = false,
                                create_date = DateTime.Now,
                                update_date = DateTime.Now
                            });
                        }else
                        {
                            //更新
                            operateContext.bllSession.T_VRDDCircleBaseService.Modify(new T_VRDDCircleBaseService { s_num = obj.s_num + 1 }, s => s.id == obj.id, "s_num");
                        }
                    }
                    #endregion
                }
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "成功保存服务信息~", "");
            }
            catch
            {
                foreach (string item in upFileNames)
                    File.Delete(uploadPath + item);
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Error, "保存服务信息失败", null);
            }
        }
        #endregion

        #region  2.1✔ 获取服务信息 + WebApiResultJsonModel GetServiceList(InputDynamicList param)
        /// <summary>
        ///  2.1✔ 获取服务信息
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        /// <remarks>
        ///  1、只返回在有效期内的服务<br/>
        ///  2、综合排序为按以下优先级对结果进行排序：<br/>
        ///      1)是否VIP（是VIP的在前）
        ///      2)是否关注（我关注的用户在前）
        ///      3)距离（距离小的在前）
        ///      4)时间（新发布的在前)
        /// </remarks>
        [HttpPost]
        public WebApiResultJsonModel<List<OutputSaveService>> GetServiceList(InputSaveService param)
        {
            //1.0 验证数据有效性
            if (!ModelState.IsValid)
                return ApiResultJsonModel<List<OutputSaveService>>.RedirectWebApi(WebResultCode.Exception, getErrorMessage(ModelState), null);
            var user = operateContext.bllSession.DD_User.FindSingle(s => s.du_id == param.user_id);
            if (user == null)
                return ApiResultJsonModel<List<OutputSaveService>>.RedirectWebApi(WebResultCode.Exception, "当前登录对象尚未完善度度圈个人信息！", null);
            if (user.gps_x == null || user.gps_y == null)
                return ApiResultJsonModel<List<OutputSaveService>>.RedirectWebApi(WebResultCode.Exception, "当前登录用户尚未保存最新gps位置信息！", null);
            List<OutputSaveService> list = operateContext.bllSession.T_VRDDCircleUserService.GetServiceList(param, (decimal)user.gps_x, (decimal)user.gps_y);
            return ApiResultJsonModel<List<OutputSaveService>>.RedirectWebApi(WebResultCode.Ok, "成功获取服务信息列表~", list);
        }
        #endregion

        #region  2.2✔ 获取服务类别信息 + WebApiResultJsonModel GetServiceType(InputService param)
        /// <summary>
        ///  2.2✔ 获取服务类别信息
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        [HttpPost]
        public WebApiResultJsonModel<List<OutputService>> GetServiceType(InputService param)
        {
            var list = operateContext.bllSession.T_VRDDScanLogin.GetServiceType(param);
            return ApiResultJsonModel<List<OutputService>>.RedirectWebApi(WebResultCode.Ok, "成功获取服务类别信息~", list);
        }
        #endregion
    }
}